﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Lrd.Permissions.CodeGenerator;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Lrd.Permissions.Demo.Web.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CodeGeneratorController : ControllerBase
    {
        private readonly ICodeGenerator _codeGenerator;
        public CodeGeneratorController(ICodeGenerator codeGenerator)
        {
            this._codeGenerator = codeGenerator;
        }


        // GET api/values
        [HttpGet]
        public ActionResult<string> Get()
        {
            var codes = _codeGenerator.GenerateProjectCode(new ProjectMetadata()
            {
                Company = "大黄瓜有限公司",
                Creator = "大黄瓜",
                Copyright = "大黄瓜",
                SiteUrl = "",
                Namespace= "Lrd.Permissions",

            });
            var savePath = @"C:\Users\Admin\Desktop\Code";
            foreach (var code in codes)
            {
                _codeGenerator.WriteAndSave(savePath, code);
            }

            return "生成成功";
        }
    }
}